import {getCapsuleGeometry, getSafeAreaGeometry, getSafeAreaInsets, getStatusBarHeight, unit} from "@/common/util";
import config from "@/uni_modules/u-tools/libs/config";

export default defineComponent({
    // 定义每个组件的属性
    props: {
        // 自定义样式
        customStyle: {
            type: [Object, String] as PropType<Record<string, any> | string>,
            default: (): Record<string, any> =>
            {
                return {};
            }
        },
        // 自定义类名
        customClass: {
            type: [Object, String] as PropType<Record<string, any> | string>,
            default: (): Record<string, any> =>
            {
                return {};
            }
        }
    },
    // 定义每个组件的计算属性
    computed: {
        // 获取u-tools的配置
        $u(): UInterface
        {
            return {
                v: config.version,
                version: config.version,
                color: config.color,
                unit: unit,
                getCapsuleGeometry: getCapsuleGeometry,
                getStatusBarHeight: getStatusBarHeight,
                getSafeAreaGeometry: getSafeAreaGeometry,
                getSafeAreaInsets: getSafeAreaInsets
            };
        }
    },
    // 定义每个组件的方法
    methods: {
        // 阻止事件冒泡
        stopPropagation(event: Record<string, any>): void
        {
            event && typeof event.stopPropagation === "function" && event.stopPropagation();
        },
        // 阻止事件默认行为
        preventDefault(event: Record<string, any>): void
        {
            event && typeof event.preventDefault === "function" && event.preventDefault();
        }
    }
});